package com.ponhu.ea2.goodsCenter.provider.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ponhu.ea2.dto.PhInventoryForGoodsCenterDto;
import com.ponhu.ea2.entity.Inventory;
import com.ponhu.ea2.goodsCenter.provider.config.DBSourceConfig;
import com.ponhu.ea2.query.LiveGoodsInfoQuery;
import com.ponhu.ea2.query.PickInventoryQuery;
import com.ponhu.ea2.scmcenter.model.dto.procurementoder.UpdateProductDto;
import com.ponhu.ea2.vo.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Entity generator.domain.Inventory
 */
public interface InventoryMapper extends BaseMapper<Inventory> {

    /**
     * 通过ID查询单条数据
     *
     * @param inventoryCode 货品编码
     * @return 实例对象
     */
    List<InventoryVo> queryByInventoryCode(@Param("inventoryCode") String inventoryCode);

    /**
     * 根据货品ID查询货品详情VO
     *
     * @param inventoryId
     * @return
     */
    PhInventoryDetailVo getInventoryDetailVoById(@Param("inventoryId") Long inventoryId);

    /**
     * 根据货品ID查询同步给胖总管的货品商品详情VO
     *
     * @param inventoryId
     * @return
     */
    PhInventoryForGoodsCenterDto getInventoryVoForPonhuById(@Param("inventoryId") Long inventoryId);

    /**
     * 根据条件分页查询选品列表数据
     *
     * @param query
     * @return
     */
    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    IPage<PickInventoryVo> getPickInventoryPageListByCondition(PickInventoryQuery query, IPage<PickInventoryVo> objectPage);

    /**
     * 根据条件分页查询选品列表数据-手动count
     *
     * @param query
     * @return
     */
    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    Long getPickInventoryPageListByCondition_count(PickInventoryQuery query);

    /**
     * 根据条件分页查询选品列表数据（针对有可售数查询条件的优化）
     *
     * @param query
     * @param objectPage
     * @return
     */
    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    IPage<PickInventoryVo> getPickInventoryPageListForStockSales(PickInventoryQuery query, IPage<PickInventoryVo> objectPage);

    /**
     * 根据条件分页查询选品列表数据-手动count（针对有可售数查询条件的优化）
     *
     * @param query
     * @return
     */
    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    Long getPickInventoryPageListForStockSales_count(PickInventoryQuery query);

    /**
     * 根据条件分页查询选品列表数据-手动count（针对有采购查询条件的专项优化）
     *
     * @param query
     * @return
     */
    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    Long getPickInventoryPageListForPurchase_count(PickInventoryQuery query);

    /**
     * 根据条件查询选品列表数据
     *
     * @param query
     * @return
     */
    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    List<PickInventoryDetailVo> getPickInventoryListByCondition(@Param("query") PickInventoryQuery query);

    /**
     * 根据条件查询选品列表数据（针对有可售数查询条件的优化）
     *
     * @param query
     * @return
     */
    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    List<PickInventoryDetailVo> getPickInventoryListForStockSales(@Param("query") PickInventoryQuery query);

    /**
     * 查询库存数据
     *
     * @param inventoryIds
     * @return
     */
    List<PickInventoryStockVo> getInventoryStockInfo(@Param("inventoryIds") List<Long> inventoryIds);

    /**
     * 获取库存在库时长数据
     *
     * @param inventoryIds
     * @return
     */
    List<PickInventoryStockVo> getInventoryWarehouseAliveDay(@Param("inventoryIds") List<Long> inventoryIds);

    /**
     * 查询库存编码数据
     *
     * @param inventoryCodeList
     * @return
     */
    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    List<PickInventoryPurchaseVo> getInventoryPurchaseInfo(@Param("inventoryCodeList") List<String> inventoryCodeList);

    /**
     * 查询商品信息给三里屯门店使用
     *
     * @param goodsCode
     * @return
     */
    GoodsInfoForAppVo getGoodsInfoByCodeForApp(String goodsCode);

    /**
     * 查询直播选品商品信息
     *
     * @param page
     * @param liveGoodsInfoQuery
     * @return
     */
    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    IPage<PhGoodsInfoForLiveVo> getGoodsInfoForLive(Page<PhGoodsInfoForLiveVo> page,
                                                    @Param("materialInfoQuery") LiveGoodsInfoQuery liveGoodsInfoQuery);

    /**
     * 直播选品商品信息总数
     *
     * @param liveGoodsInfoQuery
     * @return
     */
    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    Long getGoodsInfoForLiveCount(@Param("materialInfoQuery") LiveGoodsInfoQuery liveGoodsInfoQuery);

    /**
     * 查询修改商品信息同步采购
     *
     * @param inventoryId
     * @return
     */
    UpdateProductDto getPhInventoryByIdForPurchase(Long inventoryId);

    /**
     * 获取货品价签信息
     *
     * @param inventoryCode
     * @return
     */
    InventorBarCodeInfoVo getInventorBarCodeInfo(String inventoryCode);

    /**
     * ERP获取商品信息
     *
     * @param inventoryCode
     * @return
     */
    GoodsInfoForErpVo getGoodsInfoForErp(String inventoryCode);

    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    PickInventoryStatisticsVo getPickInventoryStatisticsByCondition(@Param("query") PickInventoryQuery query);

    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    PickInventoryStatisticsVo getPickInventoryStatisticsForPurchase(@Param("query") PickInventoryQuery query);

    @DS(DBSourceConfig.GOODSSLAVEL_DB)
    PickInventoryStatisticsVo getPickInventoryStatisticsForStockSales(@Param("query") PickInventoryQuery query);

    /**
     * 查询所有的货品信息,导出Excel
     *
     * @return
     */
    List<PhInventoryExportExcelVo> getAllInventorys();

    List<PhGoodsStatusToAmqpVo> getGoodsStatusByCode(List<String> inventoryCodes);

    List<PhGoodsPriceToAmqpVo> getGoodsPriceByCode(List<String> inventoryCodes);

    List<PhInventoryToAmqpVo> getInventoryBasicByCode(List<String> inventoryCodes);

    List<PurchaseChannelVo> getPurchaseChannelsByIds(@Param("channelIds") List<Long> channelIds);

}




